package com.flash.InventoryManagement.mapper;

import com.flash.InventoryManagement.entity.SecurityStock;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Repository;

import java.util.List;
import java.util.Map;

/**
 * @author jr
 * @version 1.0
 * @date 2022/8/10
 */

@Mapper
public interface SecurityStockMapper {
    //查询
    @Select("select * from (select rownum rn,s.* from securityStock s) s" +
            " join Security s2 on s.securityId = s2.securityId" +
            " where 1=1 ${strWhere} and rn between #{page} and #{limit}")
    public List<SecurityStock>  selectSecurityStock(Map map);

    @Select("select count(*) from securityStock")
    public int countSecurityStock();

    //增加
    @Insert("insert into securityStock values(#{securityStockId},#{fundId},#{securityId},#{datestock},#{quantity},#{unitCost},#{money},#{initialState},#{remark})")
    public int insertSecurityStock(SecurityStock securityStock);

    //删除
    @Delete("delete from securityStock where securityStockId=#{securityStockId}")
    public int deleteSecurityStock(SecurityStock securityStock);

    //修改
    @Update("update securityStock set fundId=#{fundId},securityId=#{securityId},datestock=#{datestock},quantity=#{quantity},unitCost=#{unitCost},money=#{money},initialState=#{initialState},remark=#{remark} where securityStockId=#{securityStockId}")
    public int updateSecurityStock(SecurityStock securityStock);

}
